﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 按键移动
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult aa = MessageBox.Show("Helo Work!","消息", MessageBoxButtons.YesNoCancel);

            if (aa == DialogResult.Yes)
            {
                this.Text = "yes";
            }
            else if (aa == DialogResult.No)
            {
                this.Text = "NO";
            }
            else if (aa == DialogResult.Cancel)
            {
                this.Text = "Cancel";
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("点击成功");
        }

        private void button2_MouseMove(object sender, MouseEventArgs e)
        {
            Random r = new Random(); //生成随机数
            int x = r.Next(0, this.Size.Width - this.button2.Width);  //窗体
            int y = r.Next(0, this.ClientSize.Height - this.button2.Height);  //窗体内部空间的

            Point p = new Point(x,y);

            button2.Location = p;
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("www.baidu.com");
        }

        private void button3_Click(object sender, EventArgs e)
        {
           // pictureBox1.Image = Image.FromFile("");  //输入路径
        }

        private void button4_Click(object sender, EventArgs e)
        {
            MessageBox.Show(DateTime.Now.Year.ToString());
        }
    }
}
